package com.ming_za.od_updater_sdk.processing.file;
import com.ming_za.od_updater_sdk.exception.FileUnableCreateException;
import com.ming_za.od_updater_sdk.obj.Res;

import java.io.File;

public class DefaultFileProcessor implements IFileProcessor {

    @Override
    public File getFile(String rootDir, Res res){
        File file = new File(rootDir, res.getResPath());
        if (!res.isDelete()){
            if (!file.getParentFile().exists()){
                if (!file.getParentFile().mkdirs()){
                    throw new FileUnableCreateException("无法创建文件夹-->" + file.getParentFile().getAbsolutePath());
                }
            }
        }
        return file;
    }
}
